<?php include dirname(__FILE__).'/common/header.php'; ?>

<?php include dirname(__FILE__).'/common/menu.php'; ?>

var attr = {};
attr.ctrlName = '<?php echo $ctrlName; ?>';
attr.game_gift = <?php echo $game_gift ?>;
/*
| -------------------------------------------------------------------
|  List Grid
| -------------------------------------------------------------------
*/
list.grid = new ZM.GridPanel({
    url: list.baseUrl + attr.ctrlName+'/getGiftCodeList',
    tbar:[{
    	text:'添加优惠码',
    	cls:'btn-show',
    	handler: function() {
    		var win = new ZM.PopUp({
                title:'添加优惠码',
                defaults:{labelWidth: 120},
                items:{
                    xtype:'formpanel',
                    url:list.baseUrl+ attr.ctrlName+'/createGiftCodeBatch',
                    success:function(res) {
                        ZM.bo.msg('success',res.detail);
                        list.grid.store.reload();
                        win.close();
                    },
                    items:[{
                    	xtype:'numberfield',
                    	name:'count',
                    	value:100,
                    	fieldLabel:'数量'
                    }]
                }
            }).show();
    	}
    },'-',{
        text:'导出过滤优惠码',
        cls:'btn-show',
        hidden:!Ext.permission[attr.ctrlName + '/exportGiftCodeList'.toLowerCase()],
        handler:function() {
            var sortInfo = list.grid.store.getSortState();
            if(sortInfo) {
                list.grid.store.baseParams['sort'] = sortInfo['field'];
                list.grid.store.baseParams['dir'] = sortInfo['direction'];
            }
            location.href = list.baseUrl + attr.ctrlName + '/exportGiftCodeList?'+ Ext.urlEncode(list.grid.store.baseParams);
        }
    }],
    columns:[
        {header:'优惠码id',dataIndex:'gift_code_id',hidden:true},
        {header:'优惠码',width:250,dataIndex:'gift_code',filter:{}},
        {header:'顾客ID',dataIndex:'customer_id',filter:{}},
        {header:'顾客昵称',dataIndex:'nickname',filter:{}},
        {header:'状态',width:60,dataIndex:'gift_code_status',width:65,renderer:ZM.status,filter:{
            xtype:'combofield',
            options:[['','全部'],['1','已中奖'],['0','未中奖']]
        }},
        {header:'中奖时间',dataIndex:'gift_code_time_use',width:140},
        {header:'创建时间',dataIndex:'gift_code_time_create',width:140}
    ]
});
/*
| -------------------------------------------------------------------
|  List Grid Action
| -------------------------------------------------------------------
*/


<?php include dirname(__FILE__).'/common/layout.php'; ?>
list.grid.store.load();
<?php include dirname(__FILE__).'/common/footer.php'; ?>